package model;

import java.util.Iterator;
import java.util.LinkedList;

import model.exceptions.NoObjectivesException;
import model.exceptions.NoTreesException;
import model.interfaces.Objective;
import model.interfaces.Rule;
import model.interfaces.Session;


public class ParallelSession extends Session {

	@Override
	public void verifyRules() throws NoObjectivesException, NoTreesException{
		
		super.verifyRules();
		
		for(Objective actual : objectiveList){
			LinkedList<Rule> rulesList = this.getRulesList(actual);
			for(Object object : this.objects){
				Iterator<Rule> it = rulesList.iterator();
				while(it.hasNext()){
					this.doAddObject(object, it.next());
				}
			}
			if(actual.isAchieved())
				actual.execute();
			this.clearObjective(rulesList);
		}
	}
}

